Skip to content

feat: add Realtime WebSocket and WebRTC support - #367

Open
jbeckwith-oai wants to merge 8 commits into
mainfrom
codex/realtime-support
Open

feat: add Realtime WebSocket and WebRTC support#367
jbeckwith-oai wants to merge 8 commits into
mainfrom
codex/realtime-support

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Summary

  • add block-scoped, typed Realtime WebSocket connections for conversation, sideband, transcription, and translation sessions
  • add Ruby-style session, response, conversation-item, audio-buffer, function-output, and MCP-approval helpers while preserving raw event escape hatches
  • add WebRTC SDP negotiation (raw and multipart), translation client-secret/call endpoints, and SIP/sideband controls
  • add typed events/errors, optional lazy async-websocket transport, RBI/RBS coverage, lifecycle documentation, and ten runnable examples
  • document the browser-first WebRTC architecture: Ruby owns credentials, SDP, tools, policy, and sideband; the browser owns microphone/media/WebRTC

Review-driven design

  • capability-specific connection classes prevent invalid operations from appearing in runtime discovery or type signatures
  • connect requires a block and closes on normal return, break, or application error
  • helpers accept direct Ruby keywords and add protocol envelopes internally
  • unknown additive server events remain observable without terminating a healthy session
  • translation reads while audio is uploaded; transcription uses the dedicated intent=transcription handshake
  • raw SDP responses reuse the SDK's canonical retry, logging, redaction, and observability pipeline

Validation

  • Ruby 4.0.6: 675 tests / 2,590 assertions; 0 failures, errors, or skips
  • Ruby 3.3.12: 675 tests / 2,590 assertions; 0 failures, errors, or skips
  • RuboCop: 2,653 files, no offenses
  • Sorbet: no errors
  • RBS: 1,226 files validated
  • gem package and YARD documentation builds pass
  • live service smokes passed for text, PCM audio, server-VAD conversation, transcription, full-duplex translation, MCP approval, browser WebRTC, and paired sideband control
  • SIP accept/sideband orchestration is covered locally; a carrier-originated smoke requires configured telephony and a verified incoming-call webhook

Examples

See examples/realtime/README.md for commands and expected output. The complete design, protocol lifecycle, concurrency contract, and developer-site sample audit are in realtime.md.

@jbeckwith-oai
jbeckwith-oai marked this pull request as ready for review August 11, 2026 22:51
@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 11, 2026 22:51
@openai-sdks

openai-sdks Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 10.29s for Ruby SDK PR #367.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 270ms
tests/chat-completions-create.test.ts ✅ Passed 299ms
tests/chat-completions-stream.test.ts ✅ Passed 143ms
tests/files-content-binary.test.ts ✅ Passed 262ms
tests/files-create-multipart.test.ts ✅ Passed 255ms
tests/files-list-pagination.test.ts ✅ Passed 166ms
tests/initialize-config.test.ts ✅ Passed 215ms
tests/instance-isolation.test.ts ✅ Passed 239ms
tests/models-list.test.ts ✅ Passed 317ms
tests/responses-background-lifecycle.test.ts ✅ Passed 242ms
tests/responses-body-method-errors.test.ts ✅ Passed 537ms
tests/responses-cancel-timeout.test.ts ✅ Passed 271ms
tests/responses-cancel.test.ts ✅ Passed 352ms
tests/responses-compact-retries.test.ts ✅ Passed 259ms
tests/responses-compact.test.ts ✅ Passed 332ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 208ms
tests/responses-create-advanced.test.ts ✅ Passed 235ms
tests/responses-create-disconnect.test.ts ✅ Passed 165ms
tests/responses-create-errors.test.ts ✅ Passed 416ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 151ms
tests/responses-create-retries.test.ts ✅ Passed 303ms
tests/responses-create-stream-failures.test.ts ✅ Passed 154ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 236ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.182s
tests/responses-create-stream.test.ts ✅ Passed 188ms
tests/responses-create-terminal-states.test.ts ✅ Passed 488ms
tests/responses-create-timeout.test.ts ✅ Passed 327ms
tests/responses-create.test.ts ✅ Passed 335ms
tests/responses-delete.test.ts ✅ Passed 278ms
tests/responses-input-items-errors.test.ts ✅ Passed 194ms
tests/responses-input-items-list.test.ts ✅ Passed 201ms
tests/responses-input-items-options.test.ts ✅ Passed 274ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 350ms
tests/responses-input-tokens-count.test.ts ✅ Passed 247ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.405s
tests/responses-not-found-errors.test.ts ✅ Passed 436ms
tests/responses-parse.test.ts ✅ Passed 256ms
tests/responses-retrieve-retries.test.ts ✅ Passed 269ms
tests/responses-retrieve.test.ts ✅ Passed 322ms
tests/responses-stored-method-errors.test.ts ✅ Passed 1.059s
tests/retry-behavior.test.ts ✅ Passed 1.961s
tests/sdk-error-shape.test.ts ✅ Passed 522ms

View OkTest run #31618401050

SDK merge (a4a89c299594) · head (d0174de59185) · base (d516874ebca3) · OkTest (a845fa206fa4)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79c93c74cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/openai/realtime/transports/async_websocket.rb
Comment thread lib/openai/resources/realtime/translations/calls.rb Outdated
Comment thread examples/realtime/realtime_conversation.rb
Comment thread examples/realtime/realtime_conversation.rb Outdated
Comment thread examples/realtime/websocket_text.rb Outdated
@jbeckwith-oai jbeckwith-oai added the generator Touches generated SDK files label Aug 11, 2026

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two additional issues beyond the existing unresolved Realtime threads. Leaving comments only.

Comment thread lib/openai/resources/realtime/calls.rb
Comment thread examples/realtime/sip.rb Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d422e0f20a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/realtime/realtime_conversation.rb
Comment thread examples/realtime/realtime_conversation.rb Outdated
Comment thread examples/realtime/translation.rb Outdated

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one additional current-head issue; the existing unresolved current-head threads also remain applicable. Leaving comments only.

Comment thread examples/realtime/websocket_audio.rb Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c2ce2c037

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/realtime/websocket_transcription.rb Outdated
Comment thread examples/realtime/mcp_approval.rb Outdated
Comment thread examples/realtime/translation.rb
Comment thread lib/openai/internal/transport/base_client.rb Outdated
@jbeckwith-oai
jbeckwith-oai force-pushed the codex/realtime-support branch from 9c2ce2c to 987ede3 Compare August 12, 2026 00:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 987ede3b59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/realtime/realtime_conversation.rb Outdated
Comment thread examples/realtime/websocket_audio.rb Outdated
Comment thread rbi/openai/realtime/transports/async_websocket.rbi Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1068f8a7b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/realtime/sideband.rb Outdated
Comment thread examples/realtime/sip.rb Outdated
Comment thread examples/realtime/translation.rb Outdated
Comment thread examples/realtime/realtime_conversation.rb Outdated
Comment thread rbi/openai/resources/realtime.rbi Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74ca19c719

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/realtime/translation.rb Outdated
Comment thread examples/realtime/websocket_audio.rb
Comment thread lib/openai/resources/realtime/calls.rb Outdated
Comment thread examples/realtime/websocket_text.rb

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one remaining race in the translation follow-up; leaving an inline comment only.

Comment thread examples/realtime/translation.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

generator Touches generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants